package com.aaa.marketresearch.webclient.gwt.domain;

import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;

/**
 * @author Nail
 */
public class Market {

    private Integer id;

    private String name;

    private String description;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Market() {
        this.id = null;
        this.name = "";
        this.description = "";
    }

    public Market(JSONObject jObj) {
        this.id = (int)jObj.get("id").isNumber().doubleValue();
        this.name = jObj.get("name").isString().stringValue();
        this.description = jObj.get("description").isString().stringValue();
    }

    public JSONObject getJSON() {
        JSONObject jObj = new JSONObject();
        if (this.id != null) {
            jObj.put("id", new JSONNumber(this.id));
        }
        jObj.put("name", new JSONString(this.name));
        jObj.put("description", new JSONString(this.description));

        return jObj;
    }
}
